.tree-select {
  position: relative;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;

  // 输入框
  &-input {
    position: relative;
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 30px 0 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s;

    &:hover {
      border-color: #667eea;
    }
  }

  // 打开状态
  &-open &-input {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
  }

  &-open &-arrow svg {
    transform: rotate(180deg);
  }

  // 禁用状态
  &-disabled &-input {
    background-color: #f5f5f5;
    cursor: not-allowed;
    color: #999;

    &:hover {
      border-color: #d9d9d9;
    }
  }

  // 占位符
  &-placeholder {
    color: #999;
    user-select: none;
  }

  // 显示文本
  &-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;
  }

  // 清空按钮
  &-clear {
    position: absolute;
    right: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1;

    &:hover {
      color: #666;
    }

    svg {
      display: block;
    }
  }

  // 下拉箭头
  &-arrow {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #999;
    transition: transform 0.2s;
    pointer-events: none;

    svg {
      display: block;
    }
  }

  // 下拉面板
  &-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px;
    background-color: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    animation: slideDown 0.2s ease;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  // 搜索框
  &-search {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;

    input {
      width: 100%;
      height: 32px;
      padding: 0 30px 0 10px;
      border: 1px solid #d9d9d9;
      border-radius: 4px;
      font-size: 14px;
      outline: none;
      transition: all 0.2s;

      &:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
      }

      &::placeholder {
        color: #999;
      }
    }
  }

  &-search-icon {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #999;
    pointer-events: none;

    svg {
      display: block;
    }
  }

  // 树形容器
  &-tree-wrapper {
    max-height: 600px;
    overflow-y: auto;
    padding: 8px 0;

    // 滚动条样式
    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background-color: rgba(0, 0, 0, 0.2);
      border-radius: 3px;

      &:hover {
        background-color: rgba(0, 0, 0, 0.3);
      }
    }

    &::-webkit-scrollbar-track {
      background-color: transparent;
    }
  }

  // 无数据提示
  &-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: #999;
    font-size: 14px;
  }
}
